package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * @ClassDescription:
 * @JdkVersion: 1.8
 * @Author: 李白
 * @Created: 2024/8/19 21:21
 */
public class BorrowOperation implements IOPreparation{

    public void work(BookList bookList){
        System.out.println("请输入想借阅的书名");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();
        int currentSize = bookList.getSize();
        for (int i = 0; i < currentSize; i++) {
            Book book = bookList.getBook(i);
            if (book.getName().equals(name)){
                System.out.println("借阅成功");
                book.setIsborrowed(true);
                return;
            }else {
                System.out.println("该书不存在");
            }

        }

    }
}
